from PyQt5.QtWidgets import QApplication,QWidget,QPushButton,QHBoxLayout #(用于水平布局)
from PyQt5.QtCore import *
from PyQt5.QtGui import QIcon
import sys

# 1.创建应用程序
app = QApplication(sys.argv)

# 2.创建窗口
w = QWidget()

# 3.修改窗口标题
w.setWindowTitle('水平布局')

"""----------创建按钮-----------"""
btn1 = QPushButton('1')
btn2 = QPushButton('2')
btn3 = QPushButton('3')
btn4 = QPushButton('4')
btn5 = QPushButton('5')

#创建布局
layout = QHBoxLayout()
#添加布局到窗口中
w.setLayout(layout)
#按钮控件添加到布局中
layout.addWidget(btn1)
layout.addWidget(btn2)
layout.addWidget(btn3)
layout.addWidget(btn4)
layout.addWidget(btn5)

#显示窗口
w.show()
sys.exit(app.exec_())
